package com.timedomain.him.remake.core;
import android.content.Context;
import android.content.res.AssetManager;

import com.timedomain.him.remake.Program;
import com.timedomain.him.remake.utils.HLog;

import static com.un4seen.bass.BASS.*;

public class ChannelCreator {

    public static int FromFile(Context ctx,String path){
        HLog.d("ChannelCreator", "FromFile: "+path);
        AssetManager a = ctx.getAssets();
        String actualPath ="data/"+ Program.getDataPack(ctx).get(path).hash;
        HLog.d("ChannelCreator", "FromFile: "+path+"->"+actualPath);
        return FromAsset(a,actualPath);
    }
    public static int FromAsset(AssetManager assetManager,String path){
        int handle = BASS_StreamCreateFile(new Asset(assetManager,path),0,0,0);
        int error = BASS_ErrorGetCode();
        if(error != BASS_OK){
            HLog.w("Bass create channel error,code=",""+error);
        }

        return handle;
    }
}
